import 'package:flutterlib/common/net/retrofit/im_api.dart';
import 'package:flutterlib/common/net/retrofit/interest_api.dart';
import 'package:flutterlib/model/im/group_pojo.dart';
import 'package:flutterlib/model/interest/interest_bean.dart';
import 'package:flutterlib/model/interest/interest_join.dart';
import 'package:mobx/mobx.dart';
part 'interest_store.g.dart';
class InterestStore = _InterestStore with _$InterestStore;

abstract class _InterestStore with Store {


  @observable
  ObservableFuture<InterestBean> interestFuture;

  @action
  Future fetchInterest(int id) => interestFuture
      = ObservableFuture(InterestApi.builder().getDetailById(id));

  @observable
  int interestPostCount;

  @action
  setInterestPostCount(int num){
    interestPostCount = num;
  }

  @observable
  ObservableFuture<bool> joinInterestFuture;

  @action
  Future joinInterest(InterestJoin join) => joinInterestFuture
      = ObservableFuture(InterestApi.builder().joinInterest(join));

  @observable
  ObservableFuture<List<InterestBean>> myInterestsFuture = ObservableFuture(Future.value([]));


  @action
  Future fetchMyInterest(int userId) => myInterestsFuture
  = ObservableFuture(InterestApi.builder().getMyInterests(userId));


  @observable
  ObservableFuture<List<GroupEntity>> myGroupFuture = ObservableFuture(Future.value([]));


  @action
  Future fetchMyGroup(int userId) => myGroupFuture
  = ObservableFuture(IMApi.builder().getMyGroup(userId));
}
